package com.ws.user.user.web;

import com.ws.common.easyui.util.Page;
import com.ws.user.user.service.IUserService;
import com.ws.user.user.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.stereotype.Controller;

import java.util.List;

@RequestMapping("/user")
@Controller
public class UserWeb {


    @Autowired
    IUserService userService;

    @RequestMapping("/list")
    @ResponseBody
    public List<User> list(User user,Page page){
        List<User> users=userService.list(user,page);
        return  users;
    }

    @RequestMapping("read")
    @ResponseBody
    public Object read(User user){
        return  userService.read(user.getId());
    }

    @RequestMapping("/save")
    @ResponseBody
    public Object save(User user){
        Integer count=userService.save(user);
        return  count;
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Integer delete(String id){
        return  userService.delete(id);
    }

    @RequestMapping("/insert")
    @ResponseBody
    public Object insert(User user){
        Integer count=userService.insert(user);
        return  count;
    }

    @RequestMapping("/insertSelective")
    @ResponseBody
    public Object insertSelective(User user){
        return userService.insertSelective(user);
    }

    @RequestMapping("/update")
    @ResponseBody
    public Object update(User user){
        return userService.update(user);
    }

    @RequestMapping("/edit")
    @ResponseBody
    public Object edit(User user){
        return  userService.read(user.getId());
    }

    @RequestMapping("/view")
    @ResponseBody
    public Object view(User user){
        return  userService.read(user.getId());
    }

    @RequestMapping("/listAll")
    @ResponseBody
    public Object listByMap(){
        return  userService.listAll();
    }
}
